
{include file="public/meta" /}
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>HTML模版</h5>
                    <div class="ibox-tools">
                        <a class="link">
                            <b>
                                <i class="layui-icon layui-icon-refresh"></i>
                            </b>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="tabs-container">
                            <!--form元素开始-->
                            <div class="layui-form">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="title" required  lay-verify="required" placeholder="名称" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">HTML</label>
                                    <div class="layui-input-block">
                                        <textarea name="content" placeholder="在此处粘贴HTML源码" class="layui-textarea" rows="20" required lay-verify="required"></textarea>
                                    </div>
                                </div>
                                <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element">添加</button>
                            </div>
                            <!--form元素结束-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;
            //监听提交
            form.on('submit(component-form-element)', function (data) {
                //$('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
                var index = layer.load();
                $.ajax({
                    url:"{:url('admin/template/html_template')}",
                    type:'post',
                    dataType:'json',
                    data:data.field,
                    success:function(res){
                        if (res.data == 1) {
                            layer.close(index);
                            layer.msg(res.message);
                            setTimeout('window.location.reload()',1000);
                        } else if (res.data == 0) {
                            layer.close(index);
                            layer.open({
                                title: '添加失败'
                                ,content: res.message
                            });
                        } else {
                            layer.close(index);
                            layer.open({
                                title: '添加失败'
                                ,content: '出现未知错误，如果问题一直出现，您可以联系管理员'
                            });
                        }
                    },error:function () {
                        layer.close(index);
                        layer.open({
                            title: '添加地址失败'
                            ,content: '当前网络环境不安全，拒绝登录，请调整网络环境'
                        });
                    }
                })
            });
        });
    </script>
    <!-- 全局js -->
    {include file="public/footer" /}
</body>
</html>
